package utils

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

const (
	JsonSuccessCode   = 0
	JsonFailCode      = 1
	JsonAuthFailCode  = 1000
	JsonPanicFailCode = 9000
)

// Json 统一返回
func Json(ctx *gin.Context, code int64, msg string, data interface{}) {
	json := map[string]interface{}{
		"code": code,
		"msg":  msg,
		"data": data,
	}
	ctx.Set("json", json)
	ctx.JSON(http.StatusOK, json)
}
